<%@ page import="cn.school.entity.Subject" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.school.entity.Admin" %><%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2022-02-17
  Time: 17:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>课程</title>
    <style>
       *{
           margin: 0;
           padding: 0;
       }
        #sub .header{
            list-style: none;
            display: flex;
            border:1px solid gray;
            margin-left: 3px;
            width: 70%;
            text-align: center;
        }
        .header li:nth-child(1){
            border:1px solid gray;
            width:60px;
        }
       .header li:nth-child(2){
           border:1px solid gray;
           width:260px;
       }
       .header li:nth-child(3){
           border:1px solid gray;
           width:80px;
       }
    </style>
</head>
<body>
<%@include file="/WEB-INF/checkLogin.jsp" %>
<%--<%
    Admin admin=(Admin)session.getAttribute("USER_LOGIN");
    if(admin==null){
        out.print("<script>alert('not login');location='login.jsp';</script>");
        return;
    }
    out.print("欢迎  "+admin.getName());
%>--%>
<p>
    <a href="addsubject.jsp">增加新课</a>
</p>
<p style="color: red">
    <%--<%
        String subjectn=request.getParameter("subjectname");
        out.print(subjectn+"增加成功了！");
    %>--%>
</p>
<div id="sub">
    <ul class="header">
        <li>课程号</li>
        <li>课程名</li>
        <li>课时</li>
        <li>操作</li>
    </ul>
    <%
        List<Subject> subjects = (List<Subject>) request.getAttribute("subjects");
        for(Subject s:subjects){
    %>
    <ul  class="header">
        <li><%=s.getId()%></li>
        <li><%=s.getSubjectname()%></li>
        <li><%=s.getClasshour()%></li>
        <!---相当于get提交-->
        <li><a href="subjectUpdateServlet?id=<%=s.getId()%>">修改</a> <a onclick="return window.confirm('Are you sure?')" href="delSubjectServlet?id=<%=s.getId()%>">删除</a></li>
    </ul>
    <%}%>
</div>
</body>
</html>
